package com.lmb.todo.controller;

import com.lmb.todo.dao.UserDao;
import com.lmb.todo.pojo.User;
import com.lmb.todo.utils.DateUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

@SpringBootTest
public class UserController {

    @Autowired
    private UserDao userDao;

    @Test
    public void getById() {
        User user = userDao.getById(1);
        System.out.println(user);
    }

    @Test
    public void getByUsernameAndPassword() {
        User user = userDao.getByUsernameAndPassword("root", "123456");
        System.out.println(user);
    }

    @Test
    public void addUser() {
        User user = new User();
        user.setUsername("helloWorld");
        user.setPassword("12345678");
        user.setCreateTime(DateUtil.getCurrentDateStr());
        int i = userDao.add(user);
        System.out.println((i));
    }

    @Test
    public void deleteById() {
        int i = userDao.deleteById(17);
        System.out.println(i);
    }

    @Test
    public void update() {
        User user = new User();
        user.setId(18);
        user.setUsername("HAHAHAHHAHAHA");
        user.setPassword("12312sadsad123");
        user.setUpdateTime(DateUtil.getCurrentDateStr());
        int i = userDao.update(user);
        System.out.println(i);
    }

}
